/*
 *  checkPatternScene.h
 *  opencvExample
 *
 *  Created by ycam on 11/03/04.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */
#pragma once
#include "ofMain.h"
#include "basePattern.h"


class checkPatternScene : public basePattern{
public:
	void setup(){
		allocate();
		//		numCheck = 8;	
		numCheckX = 8;
		numCheckY = 8;		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				unsigned char tmpval = i % numCheckY < numCheckY/2 
				? (j + w * i) % numCheckX < numCheckX/2 
				? maxGray : 0  :  (j + w * i) % numCheckX < numCheckX/2 
				? 0 : maxGray;								
				
				//				unsigned char tmpval = j<w/2 ? count : 255 - count;
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
	}
	void update(){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				//				unsigned char tmpval = j<w/2 ? count : 255 - count;
				//				unsigned char tmpval = i % numCheck < numCheck/2 ? (j + w * i) % numCheck < numCheck/2 ? 255:0  :  (j + w * i) % numCheck < numCheck/2 ? 0:255;								
				unsigned char tmpval = i % numCheckY < numCheckY/2 
				? (j + w * i) % numCheckY < numCheckY/2 
				? maxGray : 0  :  (j + w * i) % numCheckX < numCheckX/2 
				? 0 : maxGray;								
				
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
		currentColorImage.setFromPixels(currentColorPixels, w, h);	
		count++;
	}
	void setupWhenPatternChanged(){
		count = 0;
	}
	int count;
	int numCheckX,numCheckY;
};